package at.ac.tuwien.dse.health.dashboard;

import at.ac.tuwien.dse.health.entity.Hospital;
import at.ac.tuwien.dse.health.security.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import java.util.Date;

/**
 * @author Bernhard Nickel
 * @author Gregor Schauer
 * @author Dominik Strasser
 */
@Controller
@RequestMapping("/hospital")
public class HospitalController {
	@Inject
	HealthService service;

	@RequestMapping("/deleteSlot")
	@ResponseBody
	@Secured(Hospital.class)
	public boolean deleteSlot(@RequestParam long slotId) {
		return service.deleteSlot(slotId) != null;
	}

	@RequestMapping("/createSlot")
	@ResponseBody
	@Secured(Hospital.class)
	public boolean createSlot(@RequestParam long startDate, @RequestParam long endDate) {
		return service.createSlot(new Date(startDate), new Date(endDate)) != null;
	}
}
